package Application.FirstApplication.view.scene
{
	import Application.FirstApplication.def.Manager;
	import Application.FirstApplication.view.ViewBaseMed;
	
	import MapBase.logic.MapBase;
	import MapBase.logic.vo.MapBaseVO;
	
	import com.friendsofed.isometric.IsoObject;
	
	import def.XG;
	
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class SceneMapBase  extends EventDispatcher
	{
		public var MAPBASE_INITCOMPLET : String = "MAPBASE_INITCOMPLET";
		
		public var mapBase : MapBase;
		public var vo : MapBaseVO;
		
		public var ready : Boolean;
		
		public function SceneMapBase(mapId : String)
		{

			mapBase = new MapBase;
			mapBase.world = XG.stageLayer.world;
			mapBase.srcList = Manager.XML.MapSrc.Data["object"];
			mapBase.buildFloor = Manager.XML.EntityFloor.Data;
			
			vo = MapBase.logic.MapBase.vo;
			
			mapBase.openByURL( Manager.XML.Source.getUrl(mapId),setWorldPosition);
		}
		
		public function addEntityToWorld(entity : IsoObject,id:String) : void
		{
			mapBase.addEntityToWorld(entity,id);
		}
		
		private function setWorldPosition():void
		{
			if(vo.mapType == 2)
			{
				mapBase.setWorldLocation(0,0);
			}else if(vo.mapType == 1)
			{
				mapBase.setWorldLocation(XG.stage.stageWidth/2,0);
			}else if(vo.mapType == 3)
			{
				mapBase.setWorldLocation(0,0);
			}
			
			this.dispatchEvent(new Event(MAPBASE_INITCOMPLET));
		}
	}
}